<template>
  <!-- 攻略 -->
  <div class="strategy">
      <head-usual :title="title"></head-usual>
     <!-- 排序筛选-->
    <div class="body-all">
    <!-- 类型分类 -->
    <div class="body">
        <div class="area nav" @click="switchFilter('status')">
            <span>项目状态</span>
            <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-shang-copy-copy"></use>
            </svg>
        </div>
        <mt-popup class="tlm-popup tlm-popup-1" v-model="showStatus" position="top" popup-transition="popup-fade">
            <ul class="body-tanchu">
                <li class="area-li">
                    <a @click="handleFilter('status',0)" v-bind:class="{ active: 0==searchCondition.status }">不限</a>
                </li>
                <li v-for="(item,index) in this.$store.state.filter_ProStatu" :key="index" >
                    <a @click="handleFilter('status',item.id)" v-bind:class="{ active: item.id==searchCondition.status }">{{item.name}}</a>
                </li>
            </ul>
        </mt-popup>
        <div class="major nav" @click="switchFilter('industrycla')">
            <span>行业分类</span>
            <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-shang-copy-copy"></use>
            </svg>
        </div>
        <mt-popup class="tlm-popup tlm-popup-2" v-model="showIndustrycla" position="top" popup-transition="popup-fade">
            <ul class="body-tanchu">
                <li class="area-li" >
                    <a @click="handleFilter('industrycla',0)" v-bind:class="{ active: 0==searchCondition.industrycla }">不限</a>
                </li>
                <li v-for="(item,index) in this.$store.state.filter_Hyfl" :key="index" >
                    <a @click="handleFilter('industrycla',item.id)" v-bind:class="{ active: item.id==searchCondition.industrycla }">{{item.name}}</a>
                </li>
            </ul>
        </mt-popup>
        <div class="major-classify nav" @click="switchFilter('role')">
            <span>项目角色</span>
            <svg class="icon icon-active" aria-hidden="true">
                <use xlink:href="#icon-shang-copy-copy"></use>
            </svg>
        </div>
        <mt-popup class="tlm-popup tlm-popup-3" v-model="showRole" position="top" popup-transition="popup-fade" >
            <ul class="body-tanchu">
               <li class="area-li" >
                    <a @click="handleFilter('role','all')" v-bind:class="{ active: 'all'==searchCondition.role }">不限</a>
                </li>
                <li v-for="(item,index) in this.$store.state.filter_Role" :key="index" >
                    <a @click="handleFilter('role',item.name)" v-bind:class="{ active: item.name==searchCondition.role }">{{item.name}}</a>
                </li>
            </ul>
        </mt-popup>
    </div>
    </div>
  <!-- 分类 -->
    <div class="classify">
        <div class="classify-item">热门排序</div>
        <div class="classify-item">好评排序</div>
        <div class="classify-item active">口碑排序</div>
    </div>
      <!-- 攻略列表 -->
    <div class="gonglue-list">
                   <div class="gonglue-item">
                       <div class="item-img">
                            <img src="~@/assets/gonglue01.jpg"/>
                       </div>
                      
                       <div class="bianji-2" >
                            <p>8分29秒</p>
                            <p>
                                <svg class="icon icon-po" aria-hidden="true" >
                                    <use xlink:href="#icon-Collection-wx3"></use>
                                </svg>
                                <span>收藏</span>
                                <svg class="icon icon-po" aria-hidden="true">
                                    <use xlink:href="#icon-iconset0425"></use>
                                </svg>
                                <span>下载</span>
                            </p>
                        </div>
                        <p class="p-left">2017高级UI设计师教程</p>
                        <p class="p-right">
                            <svg class="icon icon-jia" aria-hidden="true" @click.prevent="fabu">
                                <use xlink:href="#icon-chakan"></use>
                            </svg>
                            <span>986人浏览</span>
                        </p>
                        <div class="bofang-btn">
                            <div class="sanjiao">

                            </div>
                           
                        </div>
                        <!-- 遮罩层 -->
                        <div class="hidder">

                        </div>
                   </div>
                   <div class="gonglue-item">
                       <div class="item-img">
                            <img src="~@/assets/gonglue02.jpg"/>
                       </div>
                       <div class="bianji-2" >
                           <p>8分29秒</p>
                            <p>
                                <svg class="icon icon-po" aria-hidden="true" >
                                    <use xlink:href="#icon-Collection-wx3"></use>
                                </svg>
                                <span>收藏</span>
                                <svg class="icon icon-po" aria-hidden="true">
                                    <use xlink:href="#icon-iconset0425"></use>
                                </svg>
                                <span>下载</span>
                            </p>
                        </div>
                         <p class="p-left">2017高级UI设计师教程</p>
                        <p class="p-right">
                            <svg class="icon icon-jia" aria-hidden="true" @click.prevent="fabu">
                                <use xlink:href="#icon-chakan"></use>
                            </svg>
                            <span>986人浏览</span>
                        </p>
                        <div class="bofang-btn">
                            <div class="sanjiao">
                            </div> 
                        </div>
                        <!-- 遮罩层 -->
                        <div class="hidder">

                        </div>
                   </div>

               </div>

  </div>
</template>

<script>
import { GetPagedList } from "@/api/projects";

export default {
  data() {
    return {
      title: "项目列表",
      pagedListData: [],
      showStatus: false,
      showIndustrycla: false,
      showRole: false,

      searchCondition: {
        area: "", //地区
        status: 0, //状态
        industrycla: 0, //行业分类
        role: "all", //角色
        pageindex: 1, //页码
        sort: "" //排序
      },
      loading: false, //是否显示加载中
      allLoaded: false, //加载完毕
      totalpage: 0 //总页码
    };
  },
  created() {
    this._getPagedList();
  },
  methods: {
    switchFilter(type) {
      //顶部切换 筛选条件
      switch (type) {
        case "status":
          {
            this.showStatus = true;
            this.showIndustrycla = false;
            this.showRole = false;
          }
          break;
        case "industrycla":
          {
            this.showStatus = false;
            this.showIndustrycla = true;
            this.showRole = false;
          }
          break;
        case "role":
          {
            this.showStatus = false;
            this.showIndustrycla = false;
            this.showRole = true;
          }
          break;
        default:
          break;
      }
    },
    handleFilter(type, value) {
      switch (type) {
        case "status":
          {
            this.searchCondition.status = value;
          }
          break;
        case "industrycla":
          {
            this.searchCondition.industrycla = value;
          }
          break;
        case "role":
          {
            this.searchCondition.role = value;
          }
          break;
        default:
          break;
      }

      this.showStatus = false;
      this.showIndustrycla = false;
      this.showRole = false;
      this._getPagedList();
    },
    loadMore() {
      //分页加载更多
      if (this.searchCondition.pageindex >= this.totalpage) {
        this.allLoaded = true;
        return;
      }
      this.loading = true;
      setTimeout(() => {
        this.searchCondition.pageindex++;
        GetPagedList(
          this.searchCondition.pageindex,
          this.searchCondition.status,
          this.searchCondition.industrycla,
          this.searchCondition.role,
          this.searchCondition.sort
        ).then(res => {
          if (res.StatusCode === 200) {
            this.pagedListData = this.pagedListData.concat(res.Data);
          }
        });
        this.loading = false;
      }, 1000);
    },
    // 获取数据
    _getPagedList() {
      this.$indicator.open();
      this.searchCondition.pageindex = 1;
      GetPagedList(
        this.searchCondition.pageindex,
        this.searchCondition.status,
        this.searchCondition.industrycla,
        this.searchCondition.role,
        this.searchCondition.sort
      ).then(res => {
        if (res.StatusCode === 200) {
          this.pagedListData = res.Data;
          this.totalpage = res.TotalPage;
          this.$indicator.close();
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.body-all {
  position: relative;
}
/* 分类*/
.body {
  width: 100%;
  height: 44px;
  display: flex;
  border-top: 1px solid #ccc;
  text-align: center;
  //分类下每一个选项
  .nav {
    width: 33.3%;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    line-height: 44px;
    span {
      font-size: 14px;
      color: #333333;
    }
    .icon-active {
      color: #fd4f00;
    }
  }
  // 角色分类右边框消失
  .major-classify {
    border-right: none !important;
  }
}
.body-tanchu {
  border-bottom: 1px solid #ccc;
  width: 100%;
  overflow: hidden;
  background: white;
  padding-bottom: 15px;
}
.body-tanchu > li {
  float: left;
  width: 90px;
  height: 29.3px;
  border: 1px solid #eeeeee;
  margin-left: 11px;
  margin-top: 16px;
  text-align: center;
  line-height: 29.3px;
}
.popup-layer {
  width: 414px;
  background-color: #fff;
  padding: 0;
  margin: 0;
  left: 50%;
  position: absolute;
}
// 弹出阴影层
.body-all > .v-modal {
  width: 100%;
  height: 73%;
}
.hidden {
  width: 100%;
  z-index: 99999;
  height: 88px;
  position: absolute;
  top: -44px;
  left: 0;
  background-color: white;
  opacity: 0;
}
.active {
  border-color: #fd4f00 !important;
  color: #fd4f00 !important;
}
/* 3个排序 */
.classify {
  width: 100%;
  height: 42px;
  background: #f9f9f9;
  display: flex;
  align-items: center;
  text-align: center;
  border-bottom: 1px solid #eeeeee;
  .classify-item {
    width: 33.3%;
    font-size: 12px;
    color: #282828;
  }
  .active {
    color: #fd4f00 !important;
  }
}

// 攻略页
.gonglue-list {
  padding: 5px 6px;
  background: #f4f4f4;
  padding-bottom: 75px;
}
.gonglue-item {
  width: 100%;
  position: relative;
  margin-top: 10px;
  border-radius: 3%;
  border: 1px solid transparent;
  background: #ffffff;
  // background: -webkit-linear-gradient( top, gray); /* Safari 5.1 - 6.0 */
  // background: linear-gradient(to bottom , white); /* 标准的语法（必须放在最后） */
  .item-img {
    width: 100%;
    height: 200px;
    > img {
      max-width: 100%;
      max-height: 100%;
      vertical-align: middle;
      border: 1px solid transparent;
      border-top-left-radius: 3%;
      border-top-right-radius: 3%;

      // border-radius: 5%;
    }
  }

  .hidder {
    width: 100%;
    height: 194px;
    background: -webkit-linear-gradient(
      top,
      black,
      white
    ); /* Safari 5.1 - 6.0 */
    background: -o-linear-gradient(
      bottom,
      black,
      white
    ); /* Opera 11.1 - 12.0 */
    background: -moz-linear-gradient(
      bottom,
      black,
      white
    ); /* Firefox 3.6 - 15 */
    background: linear-gradient(
      to bottom,
      black,
      white
    ); /* 标准的语法（必须放在最后） */
    position: absolute;
    top: 0px;
    z-index: 2;
    opacity: 0.1;
    border-radius: 3%;
    border: 1px solid transparent;
  }
  .p-left {
    position: absolute;
    left: 12px;
    top: 15px;
    color: #ffffff;
    z-index: 3;
  }
  .p-right {
    position: absolute;
    right: 12px;
    top: 15px;
    color: #ffffff;
    z-index: 3;
    > span {
      float: left;
      display: block;
    }
    > .icon {
      display: block;
      float: left;
      margin-top: 3px;
      margin-right: 8px;
    }
  }
  // 播放按钮
  .bofang-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 1px solid #ffffff;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -27px;
    margin-top: -42px;
    background: rgba(40, 40, 40, 0.5);
    > .sanjiao {
      width: 0;
      height: 0;
      border-top: 15px solid transparent;
      border-bottom: 15px solid transparent;
      border-left: 30px solid #ffffff;
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      margin: auto;
      margin-left: 16px;
    }
  }
  .bianji-2 {
    overflow: hidden;
    font-size: 16px;
    color: #999999;
    padding: 14px 7.5px;
    > p {
      float: left;
    }
    > :first-child {
      float: left;
    }
    > :last-child {
      float: right;
      > span {
        float: left;
        display: block;
      }
      > .icon {
        float: left;
        display: block;
        margin-top: 3.5px;
        margin-right: 7px;
        margin-left: 12px;
      }
      > :first-child {
        color: #fd4f00;
      }
      > :nth-child(2) {
        color: #fd4f00;
      }
    }
  }
}
</style>
